package com.fr.report.web.ui;

import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.web.Repository;

public class ToggleButton extends Button
{
  private static final String EVENT_STATECHANGE = "statechange";
  private boolean isSelected;

  public boolean isSelected()
  {
    return this.isSelected;
  }

  public void setSelected(boolean paramBoolean)
  {
    this.isSelected = paramBoolean;
  }

  public String getXType()
  {
    return "togglebutton";
  }

  public boolean isEditor()
  {
    return false;
  }

  public String[] supportedEvents()
  {
    return new String[] { "statechange" };
  }

  public JSONObject createJSONConfig(Object paramObject, Repository paramRepository)
    throws JSONException
  {
    JSONObject localJSONObject = super.createJSONConfig(paramObject, paramRepository);
    if (this.isSelected)
      localJSONObject.put("selected", true);
    return localJSONObject;
  }

  public boolean equals(Object paramObject)
  {
    return ((super.equals(paramObject)) && (paramObject instanceof ToggleButton) && (((ToggleButton)paramObject).isSelected == this.isSelected));
  }
}